<% provide(:title, '所有选手') %>
<h1>所有选手</h1>

<div class="row">
  <div class="large-centered large-8 columns">
    <%= render 'shared/search_form', model: 'user', holder: '输入姓名或邮箱' %>
  </div>
</div>

<div class="row">
  <div class="large-centered large-10 columns">
    <table>
      <thead>
	<tr>
	  <th>姓名</th>
	  <th>邮箱</th>
	  <th>系别</th>
	  <th>班级</th>
	  <th>队伍</th>
	  <% if signed_in? && current_user.leader? %>
	    <th></th>
	  <% end %> 
	</tr>
      </thead>
      <tbody>
	<% @users.each do |user| %>
	  <tr>
	    <td><%= link_to user.name, user_path(user) %></td>
	    <td><%= user.email %></td>
	    <td><%= user.department %></td>
	    <td><%= user.from_class %></td>
	    <td>
	      <% team = user.team %>
	      <% if team %>
		<%= link_to team.name, team_path(team) %>
	      <% end %>
	    </td>
	    <% if signed_in? && current_user.can_recircuit? && user.can_be_recircuit?%>
	      <td>
		<%= link_to "邀请加入队伍", invite_user_path(user.id), method: :post %>
	      </td>
	    <% end %>
	  </tr>
	<% end %>
      </tbody>
    </table>
  </div>
  <% if @users %>
    <%= paginate @users %>
  <% end %>
</div>
